import commonType from '@ohos.data.commonType';

export default class WrapperUtil {
  constructor() {
  }

  public static GetTestWrapper(): Object {
    let wrapper: Object = {
      noteDesc: "test",
      noteTitle: "test"
    }
    return wrapper;
  }

  public static GetTestNullWrapper(): Object {
    let wrapper: Object = {
      noteDesc: undefined,
      noteTitle: undefined
    }
    return wrapper;
  }

  public static GetAssetsWrapper2(continuableDataWithAsset: Object): Object {
    let wrapper: Object = continuableDataWithAsset;
    if (continuableDataWithAsset['ugcPics'] === undefined) {
      return wrapper;
    }

    let num: number = wrapper['ugcPics'].length;
    let i: number;
    for (i = 0; i < num; i++) {
      wrapper[`assets${i}`] = wrapper['ugcPics'][i];
    }
    return wrapper;
  }

  public static GetAssetsWrapper(picPlaceHolder: Array<string>, title: string, mainContent: string,
    ugcPics: commonType.Assets): Object {
    let wrapper: Object = {
      picPlaceHolder: picPlaceHolder,
      title: title,
      mainContent: mainContent,
      ugcPics: ugcPics
    }
    if (ugcPics === undefined) {
      return wrapper;
    }
    let num: number = ugcPics.length;
    let i: number;
    for (i = 0; i < num; i++) {
      wrapper[`asset${i}`] = ugcPics[i];
    }
    // asset（资产）：文件可以迁移，但asset数据无法迁移
    // assets（资产数组）：assets数据会迁移，但文件不会迁移
    return wrapper;
  }

  /**
   {
   ugcPic1: ugcPic1,
   ugcPic2: ugcPic2,
   asset:[ugcPic1, ugcPic2]
   }
   **/


  public static GetUndefinedAsset(): Object {
    let obj: Object = {
      name: undefined,
      uri: undefined,
      path: undefined,
      createTime: undefined,
      modifyTime: undefined,
      size: undefined
    }
    return obj;
  }


  public static generateUuid(): string {
    let uuid = '';
    for (let i = 0; i < 32; i++) {
      uuid += Math.floor(Math.random() * 16)
        .toString(16)
        .toLowerCase();
    }
    return uuid;
  }
}